﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Utility;
using Utility.Service;

namespace Site
{
    public partial class Contact : UserControl
    {
        public Contact()
        {
            InitializeComponent();
            this.myMenu.Logo = "1";
            this.Loaded += new RoutedEventHandler(Contact_Loaded);
        }

        void Contact_Loaded(object sender, RoutedEventArgs e)
        {
            //菜单下滑动画
            DoubleAnimation animation = new DoubleAnimation();
            animation.From = -83;
            animation.To = 0;
            animation.Duration = new Duration(new TimeSpan(0, 0, 1));
            Storyboard.SetTarget(animation, myMenu);
            Storyboard.SetTargetProperty(animation, new PropertyPath(Canvas.TopProperty));
            Storyboard storyboard = new Storyboard();
            storyboard.Children.Add(animation);
            storyboard.Begin();

            ServiceClient client = CUtility.GetServiceClient();
            client.ReadItemsCompleted += new EventHandler<ReadItemsCompletedEventArgs>(client_ReadItemsCompleted);
            client.ReadItemsAsync(6);
        }

        void client_ReadItemsCompleted(object sender, ReadItemsCompletedEventArgs e)
        {
            if (null == e.Error)
            {
                if (null != e.Result)
                {
                    this.htmlHost.SourceHtml = e.Result[0].Content;
                }
                this.LayoutRoot.UpdateLayout();
            }
            else
            {
                throw e.Error;
            }
        }
    }
}
